package com.ozo.boot.common.captcha.config;

import com.anji.captcha.service.CaptchaCacheService;
import com.anji.captcha.service.impl.CaptchaServiceFactory;
import com.ozo.boot.common.captcha.properties.BehaviorCaptchaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 存储策略自动配置
 *
 * @author qiangesoft
 * @date 2024-07-03
 */
@Configuration
public class BehaviorCaptchaStorageAutoConfiguration {

    @Bean(name = "behaviorCaptchaCacheService")
    public CaptchaCacheService captchaCacheService(BehaviorCaptchaProperties behaviorCaptchaProperties) {
        // 缓存类型redis/local/....
        return CaptchaServiceFactory.getCache(behaviorCaptchaProperties.getCacheType().name());
    }
}
